package com.black.opsapi.feign;

import com.black.opsapi.feign.factory.RemoteUserServiceFallbackFactory;
import com.black.opscommon.constant.SecurityConstants;
import com.black.opscommon.constant.ServiceNameConstants;
import com.black.opscommon.entity.User;
import com.black.opscommon.utils.R;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestHeader;

/**
 * @author qiang.zhang
 * @date 2019/2/1
 */
@FeignClient(value = ServiceNameConstants.UMPS_SERVICE, fallbackFactory = RemoteUserServiceFallbackFactory.class)
public interface RemoteUserService {
	/**
	 * 通过邮箱查询用户、角色信息
	 *
	 * @param username 用户名
	 * @param from     调用标志
	 * @return User
	 */
	@GetMapping("/api/users/{email}")
	R<User> findByEmail(@PathVariable("email") String username
            , @RequestHeader(SecurityConstants.FROM) String from);

	/**
	 * 通过用户名查询用户、角色信息
	 *
	 * @param username 用户名
	 * @param from     调用标志
	 * @return User
	 */
	@GetMapping("/api/users/{username}")
	R<User> findByUsername(@PathVariable("username") String username
			, @RequestHeader(SecurityConstants.FROM) String from);

}
